﻿using System;
using System.Collections.Generic;
using System.Text;
using BOHVote.DAL;
using System.Data;
using BOHVote.Common;
using BOHVote.Entity;

namespace BOHVote.BLL
{
    public static class ApplyClass
    {

        public static int getNomalApply(string strApplyPeriodID)
        {
            ApplyProvide ap = new ApplyProvide();
            return ap.getNomalApply(strApplyPeriodID);
        }

        public static int getCountApplyR(string strApplyPeriodID)
        {
            ApplyProvide ap = new ApplyProvide();
            return ap.getEvaluationApply("R", strApplyPeriodID);
        }

        public static int getCountApplyS(string strApplyPeriodID)
        {
            ApplyProvide ap = new ApplyProvide();
            return ap.getEvaluationApply("S", strApplyPeriodID);
        }

        public static DataSet getApplyDataSetByIDCardAndPeriod(string IDCard, string ApplyPeriod)
        {
            ApplyProvide ap = new ApplyProvide();
            return ap.getApplyDataSetByIDCardAndPeriod(IDCard, ApplyPeriod);
        }

        public static string getApplyIDByIDCardAndPeriod(string IDCard, string ApplyPeriod)
        {
            DataSet dst = ApplyClass.getApplyDataSetByIDCardAndPeriod(IDCard, ApplyPeriod);
            string ApplyID = dst.Tables[0].Rows[0]["ApplyID"].ToString();

            return ApplyID;
        }

        public static int ApplySave(ApplyBase applybase)
        {
            ApplyProvide ap = new ApplyProvide();
            return ap.ApplySave(applybase);
        }

        public static int ApplyUpdate(ApplyBase applybase)
        {
            ApplyProvide ap = new ApplyProvide();
            return ap.UpdateApply(applybase);
        }

        public static int ApplyPPTUpdate(string applyID, string PPTPath)
        { 
            ApplyProvide ap = new ApplyProvide();
            return ap.PPTUpdate(applyID, PPTPath);
        }

        public static DataSet dstInterViewApplys(string UnitID, string GovernID, string ApplyStyle, string ApplyType, string SpecialityID, string SubjectID, string JobRank, string ApplyPeriod)
        {
            ApplyProvide ap = new ApplyProvide();
            DataSet dst = ap.getInterViewApplys(UnitID, GovernID, ApplyStyle, ApplyType, SpecialityID, SubjectID, JobRank, ApplyPeriod);
            DataColumn c1 = new DataColumn("UnitGovernName");
            dst.Tables[0].Columns.Add(c1);
            DataColumn c2 = new DataColumn("JobRankName");
            dst.Tables[0].Columns.Add(c2);
            DataColumn c3 = new DataColumn("Speciality");
            dst.Tables[0].Columns.Add(c3);
            DataColumn c4 = new DataColumn("SubjectName");
            dst.Tables[0].Columns.Add(c4);
            DataColumn c5 = new DataColumn("ApplyStyleName");
            dst.Tables[0].Columns.Add(c5);
            foreach (DataRow dr in dst.Tables[0].Rows)
            {
                if (dr["UnitID"].ToString() != "")
                    dr["UnitGovernName"] = UnitClass.getUnitName(dr["UnitID"].ToString());
                if (dr["UnitID"].ToString() == "" && dr["GovernID"].ToString() != "")
                    dr["UnitGovernName"] = UnitClass.GetGovernName(dr["GovernID"].ToString());
                if (dr["JobRankID"].ToString() != "")
                    dr["JobRankName"] = OtherClass.getJobRankName(dr["JobRankID"].ToString());
                if (dr["SpecialityID"].ToString() != "")
                    dr["Speciality"] = Subject.getSpecialityName(dr["SpecialityID"].ToString());
                if (dr["ApplyType"].ToString() != "")
                    dr["ApplyType"] = DictManageClass.GetDicNameByValue("ApplyType", dr["ApplyType"].ToString());
                if (dr["EducationLevel"].ToString() != "")
                    dr["EducationLevel"] = DictManageClass.GetDicNameByValue("educationlevel", dr["EducationLevel"].ToString());
                if (dr["Gender"].ToString() != "")
                    dr["Gender"] = common.GenderTypeName(dr["Gender"].ToString());
                if (dr["SubjectID"].ToString() != "")
                    dr["SubjectName"] = Subject.getSubjectNameBySubjectID(dr["SubjectID"].ToString());
                if (dr["ApplyStyle"].ToString() != "")
                    dr["ApplyStyleName"] = DictManageClass.GetDicNameByValue("ApplyStyle", dr["ApplyStyle"].ToString());
            }

            return dst;
        }

        public static DataSet dstApplys(string UnitID, string GovernID, string ApplyName, string ApplyType, string SpecialityID, string SubjectID, string JobRank, string IDCard, string ApplyPeriod)
        {
           return ApplyClass.dstApplys("-1", UnitID,  GovernID,  ApplyName,  ApplyType,  SpecialityID,  SubjectID,  JobRank,  IDCard, ApplyPeriod);
        }


        public static DataSet dstApplys(string ApplyStyle,string UnitID, string GovernID, string ApplyName, string ApplyType, string SpecialityID, string SubjectID, string JobRank, string IDCard,string ApplyPeriod)
        {
            ApplyProvide ap = new ApplyProvide();
            DataSet dst = ap.getApplyDataSet(ApplyStyle,UnitID, GovernID, ApplyName, ApplyType, SpecialityID, SubjectID, JobRank, IDCard, ApplyPeriod);
            DataColumn c1 = new DataColumn("UnitGovernName");
            dst.Tables[0].Columns.Add(c1);
            DataColumn c2 = new DataColumn("JobRankName");
            dst.Tables[0].Columns.Add(c2);
            DataColumn c3 = new DataColumn("Speciality");
            dst.Tables[0].Columns.Add(c3);
            DataColumn c4 = new DataColumn("SubjectName");
            dst.Tables[0].Columns.Add(c4);
            DataColumn c5 = new DataColumn("ApplyStyleName");
            dst.Tables[0].Columns.Add(c5);
            //DataColumn c6 = new DataColumn("PPTIsUpload");
            //dst.Tables[0].Columns.Add(c6);
            foreach (DataRow dr in dst.Tables[0].Rows)
            {
                if (dr["UnitID"].ToString() != "")
                    dr["UnitGovernName"] = UnitClass.getUnitName(dr["UnitID"].ToString());
                if (dr["UnitID"].ToString() == "" && dr["GovernID"].ToString() != "")
                    dr["UnitGovernName"] = UnitClass.GetGovernName(dr["GovernID"].ToString());
                if (dr["JobRankID"].ToString() != "")
                    dr["JobRankName"] = OtherClass.getJobRankName(dr["JobRankID"].ToString());
                if (dr["SpecialityID"].ToString() != "")
                    dr["Speciality"] = Subject.getSpecialityName(dr["SpecialityID"].ToString());
                if (dr["ApplyType"].ToString() != "")
                    dr["ApplyType"] = DictManageClass.GetDicNameByValue("ApplyType", dr["ApplyType"].ToString());
                if (dr["EducationLevel"].ToString() != "")
                    dr["EducationLevel"] = DictManageClass.GetDicNameByValue("educationlevel", dr["EducationLevel"].ToString());
                if (dr["Gender"].ToString() != "")
                    dr["Gender"] = common.GenderTypeName(dr["Gender"].ToString());
                if (dr["SubjectID"].ToString() != "")
                    dr["SubjectName"] = Subject.getSubjectNameBySubjectID(dr["SubjectID"].ToString());
                if (dr["ApplyStyle"].ToString() != "")
                    dr["ApplyStyleName"] = DictManageClass.GetDicNameByValue("ApplyStyle", dr["ApplyStyle"].ToString());
               
            }

            return dst;
        }
        public static int deleteApply(string applyid)
        {
            ApplyProvide ap = new ApplyProvide();
            return ap.DeleteApply(applyid);
        }

        public static DataSet getApplyByID(string applyid)
        {
            ApplyProvide ap = new ApplyProvide();
            DataSet dst = ap.getApplyID(applyid);
            DataColumn c1 = new DataColumn("UnitGovernName");
            dst.Tables[0].Columns.Add(c1);
            DataColumn c2 = new DataColumn("JobRankName");
            dst.Tables[0].Columns.Add(c2);
            DataColumn c3 = new DataColumn("Speciality");
            dst.Tables[0].Columns.Add(c3);
            DataColumn c4 = new DataColumn("SubjectName");
            dst.Tables[0].Columns.Add(c4);
            DataColumn c5 = new DataColumn("ApplyStyleName");
            dst.Tables[0].Columns.Add(c5);
            foreach (DataRow dr in dst.Tables[0].Rows)
            {
                if (dr["UnitID"].ToString() != "")
                    dr["UnitGovernName"] = UnitClass.getUnitName(dr["UnitID"].ToString());
                if (dr["UnitID"].ToString() == "" && dr["GovernID"].ToString() != "")
                    dr["UnitGovernName"] = UnitClass.GetGovernName(dr["GovernID"].ToString());
                if (dr["JobRankID"].ToString() != "")
                    dr["JobRankName"] = OtherClass.getJobRankName(dr["JobRankID"].ToString());
                if (dr["SubjectID"].ToString() != "")
                    dr["SubjectName"] = Subject.getSubjectNameBySubjectID(dr["SubjectID"].ToString());
                if (dr["ApplyStyle"].ToString() != "")
                    dr["ApplyStyleName"] = DictManageClass.GetDicNameByValue("ApplyStyle", dr["ApplyStyle"].ToString());
                if (!String.IsNullOrEmpty(dr["SpecialityID"].ToString()))
                    dr["Speciality"] = Subject.getSpecialityName(dr["SpecialityID"].ToString());
            }

            return dst;
        }

        public static DataSet dstThesis(string applyid)
        {
            ApplyProvide ap = new ApplyProvide();
            return ap.dstThesis(applyid);
        }

        public static DataSet dstApplyPublicity(string applyID)
        {
            ApplyProvide ap = new ApplyProvide();
            DataSet dst = ap.dstApplyPublicity(applyID);
            
            return dst;
        }

        public static int CountApply(string Period, string UnitID, string GovernID)
        {
            ApplyProvide ap = new ApplyProvide();
            return ap.countApplyByPeriod(Period,UnitID, GovernID);
        }

        public static int UpdateApplyUnActived(string ApplyID)
        {
            ApplyProvide ap = new ApplyProvide();
            return ap.UpdateApplyUnActived(ApplyID);
        }

        public static DataSet getApplyEvaluationByApplyID(string ApplyID)
        {
            ApplyProvide ap = new ApplyProvide();
            return ap.getApplyEvaluation("",ApplyID, "-1", "-1", string.Empty,string.Empty,string.Empty, "-1", "-1", "-1", "-1", "");
        }

        public static DataSet dstApplyEvaluation(string EvaluationResult, string UnitID, string GovernID, string ApplyName, string IDCard, string ApplyPrintID, string ApplyType, string SpecialityID, string SubjectID, string JobRank, string ApplyPeriod)
        {
            ApplyProvide ap = new ApplyProvide();
            DataSet dst = ap.getApplyEvaluation(EvaluationResult,"", UnitID, GovernID, ApplyName, IDCard, ApplyPrintID, ApplyType, SpecialityID, SubjectID, JobRank, ApplyPeriod);
            DataColumn c1 = new DataColumn("UnitGovernName");
            dst.Tables[0].Columns.Add(c1);
            DataColumn c2 = new DataColumn("JobRankName");
            dst.Tables[0].Columns.Add(c2);
            DataColumn c4 = new DataColumn("SubjectName");
            dst.Tables[0].Columns.Add(c4);
            DataColumn c5 = new DataColumn("ApplyStyleName");
            dst.Tables[0].Columns.Add(c5);
            foreach (DataRow dr in dst.Tables[0].Rows)
            {
                if (dr["UnitID"].ToString() != "")
                    dr["UnitGovernName"] = UnitClass.getUnitName(dr["UnitID"].ToString());
                if (dr["UnitID"].ToString() == "" && dr["GovernID"].ToString() != "")
                    dr["UnitGovernName"] = UnitClass.GetGovernName(dr["GovernID"].ToString());
                if (dr["JobRankID"].ToString() != "")
                    dr["JobRankName"] = OtherClass.getJobRankName(dr["JobRankID"].ToString());
                if (dr["SpecialityID"].ToString() != "")
                    dr["SpecialityID"] = Subject.getSpecialityName(dr["SpecialityID"].ToString());
                if (dr["ApplyType"].ToString() != "")
                    dr["ApplyType"] = DictManageClass.GetDicNameByValue("ApplyType", dr["ApplyType"].ToString());//common.ApplyTypeName(dr["ApplyType"].ToString());
                if (dr["EducationLevel"].ToString() != "")
                    dr["EducationLevel"] = DictManageClass.GetDicNameByValue("educationlevel", dr["EducationLevel"].ToString());
                if (dr["Gender"].ToString() != "")
                    dr["Gender"] = common.GenderTypeName(dr["Gender"].ToString());
                if (dr["SubjectID"].ToString() != "")
                    dr["SubjectName"] = Subject.getSubjectNameBySubjectID(dr["SubjectID"].ToString());
                if (dr["ApplyStyle"].ToString() != "")
                    dr["ApplyStyleName"] = DictManageClass.GetDicNameByValue("ApplyStyle", dr["ApplyStyle"].ToString());
                if (!String.IsNullOrEmpty(dr["EvaluationResult"].ToString()))
                {
                    dr["ApplyPrintID"] = OtherClass.getDictDisplayByValue(dr["EvaluationResult"].ToString(), "ApplyEvaluation");
                }
            }
            return dst;
        }

        public static int DeleteApplyEvaluaton(string ApplyID, string UserID)
        {
            ApplyProvide ap = new ApplyProvide();
            return ap.DeleteApplyEvaluaton(ApplyID, UserID);
        }

        public static int SaveApplyEvaluation(string ApplyID, string EvaluationResult, string Remark, string UserID)
        {
            ApplyProvide ap = new ApplyProvide();
            if (EvaluationResult.ToUpper() == "B")
            {
                return ap.DeleteApplyEvaluaton(ApplyID, UserID);
            }
            int CountEvaluation = ap.CountApplyEvaluation(ApplyID);
            if (CountEvaluation != 0)
            {
                return ap.UpdateApplyEvaluation(ApplyID, EvaluationResult, Remark, UserID);
            }
            else
            {
                return ap.InsertApplyEvalutation(ApplyID, EvaluationResult, Remark, UserID);
            }
        }

        //public static DataSet getApplyEvaluationByApplyPeriod(string ApplyPeriod)
        //{
        //    ApplyProvide ap = new ApplyProvide();
        //    return ap.getApplyEvaluation("", ApplyPeriod);
        //}

        public static bool BuildNumber(string ApplyPeriod)
        {
            ApplyProvide ap = new ApplyProvide();
            byte returnValue = ap.BuildPrintNumber(ApplyPeriod);
            return Convert.ToBoolean(returnValue);
        }

        public static bool buildNumberSubject(string ApplyPeriod, string SubjectID)
        {
            ApplyProvide ap = new ApplyProvide();
            byte returnValue = ap.BuildPrintNumberSubject(ApplyPeriod, SubjectID);
            return Convert.ToBoolean(returnValue);
        }

        public static bool CleanBuildNumber(string ApplyPeriod, string SubjectID)
        {
            ApplyProvide ap = new ApplyProvide();
            int returnValue = ap.CleanPrintNumber(ApplyPeriod, SubjectID);
            if (returnValue != 0)
                return true;
            else
                return false;
        }
        public static int CountUnBuildNumber(string ApplyPeriod)
        {
            return CountUnBuildNumber(ApplyPeriod, "");
        }

        public static int CountUnBuildNumber(string ApplyPeriod,string SubjectID)
        {
            ApplyProvide ap = new ApplyProvide();
            return ap.CountUnBuildNumber(ApplyPeriod, SubjectID);
        }

        public static DataSet dstApplysForInterview(string ApplyName,string ApplyPrintID,string UnitID, string GovernID, string ApplyStyle, string ApplyType, string SpecialityID, string SubjectID, string JobRank, string ApplyPeriod)
        {
            ApplyProvide ap = new ApplyProvide();
            DataSet dst = ap.getApplyInterViewDataSet(ApplyName,ApplyPrintID, UnitID, GovernID, ApplyStyle, ApplyType, SpecialityID, SubjectID, JobRank, ApplyPeriod);
            DataColumn c1 = new DataColumn("UnitGovernName");
            dst.Tables[0].Columns.Add(c1);
            DataColumn c2 = new DataColumn("JobRankName");
            dst.Tables[0].Columns.Add(c2);
            DataColumn c3 = new DataColumn("SpecialityName");
            dst.Tables[0].Columns.Add(c3);
            DataColumn c4 = new DataColumn("SubjectName");
            dst.Tables[0].Columns.Add(c4);
            DataColumn c5 = new DataColumn("CurrentJobRankName");
            dst.Tables[0].Columns.Add(c5);
            DataColumn c6 = new DataColumn("ApplyStyleName");
            dst.Tables[0].Columns.Add(c6);
            foreach (DataRow dr in dst.Tables[0].Rows)
            {
                if (dr["UnitID"].ToString() != "")
                    dr["UnitGovernName"] = UnitClass.getUnitName(dr["UnitID"].ToString());
                if (dr["UnitID"].ToString() == "" && dr["GovernID"].ToString() != "")
                    dr["UnitGovernName"] = UnitClass.GetGovernName(dr["GovernID"].ToString());
                if (dr["JobRankID"].ToString() != "")
                    dr["JobRankName"] = OtherClass.getJobRankName(dr["JobRankID"].ToString());

                if (dr["CurrentJobRankID"].ToString() != "")
                    dr["CurrentJobRankName"] = OtherClass.getJobRankName(dr["CurrentJobRankID"].ToString());

                if (dr["SpecialityID"].ToString() != "")
                    dr["SpecialityName"] = Subject.getSpecialityName(dr["SpecialityID"].ToString());
                if (dr["ApplyType"].ToString() != "")
                    dr["ApplyType"] = DictManageClass.GetDicNameByValue("ApplyType", dr["ApplyType"].ToString());
                if (dr["EducationLevel"].ToString() != "")
                    dr["EducationLevel"] = DictManageClass.GetDicNameByValue("educationlevel", dr["EducationLevel"].ToString());
                if (dr["Gender"].ToString() != "")
                    dr["Gender"] = common.GenderTypeName(dr["Gender"].ToString());
                if (dr["SubjectID"].ToString() != "")
                    dr["SubjectName"] = Subject.getSubjectNameBySubjectID(dr["SubjectID"].ToString());
                if (dr["ApplyStyle"].ToString() != "")
                    dr["ApplyStyleName"] = DictManageClass.GetDicNameByValue("ApplyStyle", dr["ApplyStyle"].ToString());
            }

            return dst;
        }

        public static DataSet dstApplyInterviewByPrintID(string applyPrintID)
        {
            ApplyProvide ap = new ApplyProvide();
            return ap.getApplyInterviewByPrintID(applyPrintID);
        }

        public static DataSet dstApplyInterview(string ApplyID, string ApplyPeriod)
        {
            ApplyProvide ap = new ApplyProvide();
            return ap.getApplyInteview(ApplyID, ApplyPeriod);
        }

        public static int SaveInterview(string ApplyID, string ApplyPeriod, string Month, string day, string HH, string MM)
        {
            ApplyProvide ap = new ApplyProvide();
            return ap.saveInterview(ApplyID,  ApplyPeriod,  Month,  day,  HH,  MM);
        }

        public static int UpdateInterview(string ApplyID, string InterviewID, string ApplyPeriod, string Month, string day, string HH, string MM)
        {
            ApplyProvide ap = new ApplyProvide();
            return ap.UpdateInterview(ApplyID,InterviewID, ApplyPeriod, Month, day, HH, MM);
        }

        public static bool UpdateAllInterview(string SubjectID, string JobRank, string ApplyPeriod, string Month, string Day, string HH, string MM)
        {
            byte returnValue = 0;
            ApplyProvide ap = new ApplyProvide();
            returnValue= ap.setInterviewTime(SubjectID, JobRank, ApplyPeriod, Month, Day, HH, MM);
            return Convert.ToBoolean(returnValue);
        }

        public static int  UpdateSingleInterview(string ApplyID, string InterviewID, string ApplyPeriod, string Month, string day, string HH, string MM)
        {
            ApplyProvide ap = new ApplyProvide();
            int intervieiwid = 0;
            if (!string.IsNullOrEmpty(InterviewID))
            {
                intervieiwid = Convert.ToInt32(InterviewID);
            }
            return ap.UpdateSingleInterView(Convert.ToInt32(ApplyID), intervieiwid, ApplyPeriod, Month, day, HH, MM);
        }


        #region <<  For Rerpot  >>

        public static DataSet dstAllInfoApplys(string UnitID, string GovernID, string ApplyName, string ApplyType, string SpecialityID, string SubjectID, string JobRank,string IDCard, string ApplyPeriod)
        {
            ApplyProvide ap = new ApplyProvide();
            DataSet dst = ap.getApplyDataSet("-1",UnitID, GovernID, ApplyName, ApplyType, SpecialityID, SubjectID, JobRank, IDCard,ApplyPeriod);
            DataColumn dc = new DataColumn("UnitGovernName");
            dst.Tables[0].Columns.Add(dc);
            DataColumn dcJ1 = new DataColumn("JournalsNo1");
            dst.Tables[0].Columns.Add(dcJ1);
            DataColumn dcT1 = new DataColumn("ThesisTitle1");
            dst.Tables[0].Columns.Add(dcT1);
            DataColumn dcJ2 = new DataColumn("JournalsNo2");
            dst.Tables[0].Columns.Add(dcJ2);
            DataColumn dcT2 = new DataColumn("ThesisTitle2");
            dst.Tables[0].Columns.Add(dcT2);
            DataColumn dcJ3 = new DataColumn("JournalsNo3");
            dst.Tables[0].Columns.Add(dcJ3);
            DataColumn dcT3 = new DataColumn("ThesisTitle3");
            dst.Tables[0].Columns.Add(dcT3);
            DataColumn dcJ4 = new DataColumn("JournalsNo4");
            dst.Tables[0].Columns.Add(dcJ4);
            DataColumn dcT4 = new DataColumn("ThesisTitle4");
            dst.Tables[0].Columns.Add(dcT4);
            DataColumn dcP1 = new DataColumn("PeriodicalNo1");
            dst.Tables[0].Columns.Add(dcP1);
            DataColumn dcP2 = new DataColumn("PeriodicalNo2");
            dst.Tables[0].Columns.Add(dcP2);
            DataColumn dcP3 = new DataColumn("PeriodicalNo3");
            dst.Tables[0].Columns.Add(dcP3);
            DataColumn dcP4 = new DataColumn("PeriodicalNo4");
            dst.Tables[0].Columns.Add(dcP4);
            DataColumn dcGovernName = new DataColumn("GovernName");
            dst.Tables[0].Columns.Add(dcGovernName);

            DataColumn dcsubject = new DataColumn("IDSubject");
            dst.Tables[0].Columns.Add(dcsubject);
            DataColumn dcJobRank = new DataColumn("IDJobRank");
            dst.Tables[0].Columns.Add(dcJobRank);

            DataColumn dcPublicityStartMonth = new DataColumn("startmonth");
            dst.Tables[0].Columns.Add(dcPublicityStartMonth);
            DataColumn dcstartday = new DataColumn("startday");
            dst.Tables[0].Columns.Add(dcstartday);
            DataColumn dcendmonth = new DataColumn("endmonth");
            dst.Tables[0].Columns.Add(dcendmonth);
            DataColumn dcendday = new DataColumn("endday");
            dst.Tables[0].Columns.Add(dcendday);
            DataColumn dcaddress = new DataColumn("address");
            dst.Tables[0].Columns.Add(dcaddress);
            DataColumn dcresponse = new DataColumn("response");
            dst.Tables[0].Columns.Add(dcresponse);

            foreach (DataRow dr in dst.Tables[0].Rows)
            {
                if (!string.IsNullOrEmpty(dr["GovernID"].ToString()))
                    dr["GovernName"] = UnitClass.GetGovernName(dr["GovernID"].ToString());

                if (!string.IsNullOrEmpty(dr["UnitID"].ToString()))
                    dr["UnitGovernName"] = UnitClass.getUnitName(dr["UnitID"].ToString());
                else if (!string.IsNullOrEmpty(dr["GovernID"].ToString()))
                    dr["UnitGovernName"] = UnitClass.GetGovernName(dr["GovernID"].ToString());
                
                if(!string.IsNullOrEmpty(dr["ApplyStyle"].ToString()))
                    dr["ApplyStyle"] = OtherClass.getApplyStyleDisply(dr["ApplyStyle"].ToString());

                if (dr["JobRankID"].ToString() != "")
                {
                    dr["IDJobRank"] = dr["JobRankID"].ToString();
                    dr["JobRankID"] = OtherClass.getJobRankName(dr["JobRankID"].ToString());
                }

                if (dr["GovernID"].ToString() != "")
                    dr["GovernID"] = UnitClass.GetGovernName(dr["GovernID"].ToString());

                if (dr["SpecialityID"].ToString() != "")
                    dr["SpecialityID"] = Subject.getSpecialityName(dr["SpecialityID"].ToString());

                if (dr["SubjectID"].ToString() != "")
                {
                    dr["IDSubject"] = dr["SubjectID"].ToString();
                    dr["SubjectID"] = Subject.getSubjectNameBySubjectID(dr["SubjectID"].ToString());
                }

                if (dr["CurrentSpecialityID"].ToString() != "")
                    dr["CurrentSpecialityID"] = Subject.getSpecialityName(dr["CurrentSpecialityID"].ToString());

                if (dr["CurrentJobRankID"].ToString() != "")
                    dr["CurrentJobRankID"] = OtherClass.getJobRankName(dr["CurrentJobRankID"].ToString());

                if (dr["ComputerResult"].ToString() != "")
                    dr["ComputerResult"] = DictManageClass.GetDicNameByValue("ComputerResult", dr["ComputerResult"].ToString());


                if (dr["ApplyType"].ToString() != "")
                    dr["ApplyType"] = DictManageClass.GetDicNameByValue("ApplyType",dr["ApplyType"].ToString());

                if (dr["UnitType"].ToString() != "")
                    dr["UnitType"] = common.UnitType(dr["UnitType"].ToString());

                if (dr["EducationLevel"].ToString() != "")
                    dr["EducationLevel"] = DictManageClass.GetDicNameByValue("educationlevel", dr["EducationLevel"].ToString());

                if (dr["ApplyPeriodID"].ToString() != "")
                    dr["ApplyPeriodID"] = dr["ApplyPeriodID"].ToString();

                if (dr["Gender"].ToString() != "")
                    dr["Gender"] = common.GenderTypeName(dr["Gender"].ToString());

                if (dr["Applyplight"].ToString() != "")
                    dr["Applyplight"] = common.Applyplight(dr["Applyplight"].ToString());

                if (dr["ForeignLanguageName"].ToString() != "")
                    dr["ForeignLanguageName"] = OtherClass.getLanguageName(dr["ForeignLanguageName"].ToString());

                if (dr["ForeignLanguageResult"].ToString() != "")
                    dr["ForeignLanguageResult"] = DictManageClass.GetDicNameByValue("ForeignLanguageResult", dr["ForeignLanguageResult"].ToString());

                if (dr["FixedJob"].ToString() != "")
                    dr["FixedJob"] = DictManageClass.GetDicNameByValue("FixedJob", dr["FixedJob"].ToString());

                if (dr["SpecialityLevel"].ToString() != "")
                    dr["SpecialityLevel"] = DictManageClass.GetDicNameByValue("SpecialityLevel", dr["SpecialityLevel"].ToString());


                if (dr["AwardsLevel"].ToString() != "")
                    dr["AwardsLevel"] = DictManageClass.GetDicNameByValue("AwardsLevel", dr["AwardsLevel"].ToString());

                if (dr["AwardsRank"].ToString() != "")
                    dr["AwardsRank"] = DictManageClass.GetDicNameByValue("AwardsRank", dr["AwardsRank"].ToString());

                if (dr["SpecialitPersonalRank"].ToString() != "")
                    dr["SpecialitPersonalRank"] = DictManageClass.GetDicNameByValue("SpecialitPersonalRank", dr["SpecialitPersonalRank"].ToString());

                if (dr["AwardsPersonalRank"].ToString() != "")
                    dr["AwardsPersonalRank"] = dr["AwardsPersonalRank"].ToString();

                if (dr["AwardsLevel1"].ToString() != "")
                    dr["AwardsLevel1"] = DictManageClass.GetDicNameByValue("AwardsLevel", dr["AwardsLevel1"].ToString());

                if (dr["AwardsRank1"].ToString() != "")
                    dr["AwardsRank1"] = DictManageClass.GetDicNameByValue("AwardsRank", dr["AwardsRank1"].ToString());

                if (dr["SpecialitPersonalRank1"].ToString() != "")
                    dr["SpecialitPersonalRank1"] = DictManageClass.GetDicNameByValue("SpecialitPersonalRank", dr["SpecialitPersonalRank1"].ToString());


                if (dr["SpecialityLevel1"].ToString() != "")
                    dr["SpecialityLevel1"] = DictManageClass.GetDicNameByValue("SpecialityLevel", dr["SpecialityLevel1"].ToString());

                if (dr["AwardsPersonalRank1"].ToString() != "")
                    dr["AwardsPersonalRank1"] = dr["AwardsPersonalRank1"].ToString();

                DataSet dstApplyPublicity = ApplyClass.dstApplyPublicity(dr["ApplyID"].ToString());
                foreach (DataRow drPubilcity in dstApplyPublicity.Tables[0].Rows)
                {
                    dr["startmonth"] = drPubilcity["startmonth"].ToString();
                    dr["startday"] = drPubilcity["startday"].ToString();
                    dr["endmonth"] = drPubilcity["endmonth"].ToString();
                    dr["endday"] = drPubilcity["endday"].ToString();
                    dr["address"] = drPubilcity["address"].ToString();
                    dr["response"] = drPubilcity["response"].ToString();
                }

                DataSet dstThesis = ApplyClass.dstThesis(dr["ApplyID"].ToString());
                foreach (DataRow drThesis in dstThesis.Tables[0].Rows)
                {
                    switch (drThesis["SeqID"].ToString())
                    {

                        case "1":
                            dr["JournalsNo1"] = drThesis["JournalsNo"].ToString();
                            dr["ThesisTitle1"] = drThesis["ThesisTitle"].ToString();
                            dr["PeriodicalNo1"] = drThesis["PeriodicalNo"].ToString();
                            break;
                        case "2":
                            dr["JournalsNo2"] = drThesis["JournalsNo"].ToString();
                            dr["ThesisTitle2"] = drThesis["ThesisTitle"].ToString();
                            dr["PeriodicalNo2"] = drThesis["PeriodicalNo"].ToString();
                            break;
                        case "3":
                            dr["JournalsNo3"] = drThesis["JournalsNo"].ToString();
                            dr["ThesisTitle3"] = drThesis["ThesisTitle"].ToString();
                            dr["PeriodicalNo3"] = drThesis["PeriodicalNo"].ToString();
                            break;
                        case "4":
                            dr["JournalsNo4"] = drThesis["JournalsNo"].ToString();
                            dr["ThesisTitle4"] = drThesis["ThesisTitle"].ToString();
                            dr["PeriodicalNo4"] = drThesis["PeriodicalNo"].ToString();
                            break;
                        default: break;
                    }
                }

            }
            return dst;
        }

        public static DataSet getApplyInfo(string ApplyID,string UnitID,string GovernID,string ApplyPeriod)
        {
            ApplyProvide ap = new ApplyProvide();
            DataSet dst = ap.getApplyByID(ApplyID, ApplyPeriod, UnitID, GovernID);
            DataColumn dc = new DataColumn("UnitGovernName");
            dst.Tables[0].Columns.Add(dc);
            DataColumn dcJ1 = new DataColumn("JournalsNo1");
            dst.Tables[0].Columns.Add(dcJ1);
            DataColumn dcT1 = new DataColumn("ThesisTitle1");
            dst.Tables[0].Columns.Add(dcT1);
            DataColumn dcJ2 = new DataColumn("JournalsNo2");
            dst.Tables[0].Columns.Add(dcJ2);
            DataColumn dcT2 = new DataColumn("ThesisTitle2");
            dst.Tables[0].Columns.Add(dcT2);
            DataColumn dcJ3 = new DataColumn("JournalsNo3");
            dst.Tables[0].Columns.Add(dcJ3);
            DataColumn dcT3 = new DataColumn("ThesisTitle3");
            dst.Tables[0].Columns.Add(dcT3);
            DataColumn dcJ4 = new DataColumn("JournalsNo4");
            dst.Tables[0].Columns.Add(dcJ4);
            DataColumn dcT4 = new DataColumn("ThesisTitle4");
            dst.Tables[0].Columns.Add(dcT4);
            DataColumn dcP1 = new DataColumn("PeriodicalNo1");
            dst.Tables[0].Columns.Add(dcP1);
            DataColumn dcP2 = new DataColumn("PeriodicalNo2");
            dst.Tables[0].Columns.Add(dcP2);
            DataColumn dcP3 = new DataColumn("PeriodicalNo3");
            dst.Tables[0].Columns.Add(dcP3);
            DataColumn dcP4 = new DataColumn("PeriodicalNo4");
            dst.Tables[0].Columns.Add(dcP4);
            DataColumn dcGovernName = new DataColumn("GovernName");
            dst.Tables[0].Columns.Add(dcGovernName);


            DataColumn dcsubject = new DataColumn("IDSubject");
            dst.Tables[0].Columns.Add(dcsubject);
            DataColumn dcJobRank= new DataColumn("IDJobRank");
            dst.Tables[0].Columns.Add(dcJobRank);

            DataColumn dcPublicityStartMonth = new DataColumn("startmonth");
            dst.Tables[0].Columns.Add(dcPublicityStartMonth);
            DataColumn dcstartday = new DataColumn("startday");
            dst.Tables[0].Columns.Add(dcstartday);
            DataColumn dcendmonth = new DataColumn("endmonth");
            dst.Tables[0].Columns.Add(dcendmonth);
            DataColumn dcendday = new DataColumn("endday");
            dst.Tables[0].Columns.Add(dcendday);
            DataColumn dcaddress = new DataColumn("address");
            dst.Tables[0].Columns.Add(dcaddress);
            DataColumn dcresponse = new DataColumn("response");
            dst.Tables[0].Columns.Add(dcresponse);

            foreach (DataRow dr in dst.Tables[0].Rows)
            {
                if (!string.IsNullOrEmpty(dr["GovernID"].ToString()))
                    dr["GovernName"] = UnitClass.GetGovernName(dr["GovernID"].ToString());
                if (!string.IsNullOrEmpty(dr["UnitID"].ToString()))
                    dr["UnitGovernName"] = UnitClass.getUnitName(dr["UnitID"].ToString());
                else if (!string.IsNullOrEmpty(dr["GovernID"].ToString()))
                    dr["UnitGovernName"] = UnitClass.GetGovernName(dr["GovernID"].ToString());

                if (!string.IsNullOrEmpty(dr["ApplyStyle"].ToString()))
                    dr["ApplyStyle"] = OtherClass.getApplyStyleDisply(dr["ApplyStyle"].ToString());

                if (dr["JobRankID"].ToString() != "")
                {
                    dr["IDJobRank"] = dr["JobRankID"].ToString();
                    dr["JobRankID"] = OtherClass.getJobRankName(dr["JobRankID"].ToString());
                }

                if (dr["GovernID"].ToString() != "")
                    dr["GovernID"] = UnitClass.GetGovernName(dr["GovernID"].ToString());

                if (dr["SpecialityID"].ToString() != "")
                    dr["SpecialityID"] = Subject.getSpecialityName(dr["SpecialityID"].ToString());

                if (dr["SubjectID"].ToString() != "")
                {
                    dr["IDSubject"] = dr["SubjectID"].ToString();
                    dr["SubjectID"] = Subject.getSubjectNameBySubjectID(dr["SubjectID"].ToString());
                }

                if (dr["CurrentSpecialityID"].ToString() != "")
                    dr["CurrentSpecialityID"] = Subject.getSpecialityName(dr["CurrentSpecialityID"].ToString());

                if (dr["CurrentJobRankID"].ToString() != "")
                    dr["CurrentJobRankID"] = OtherClass.getJobRankName(dr["CurrentJobRankID"].ToString());

                if (dr["ComputerResult"].ToString() != "")
                    dr["ComputerResult"] = DictManageClass.GetDicNameByValue("ComputerResult", dr["ComputerResult"].ToString());


                if (dr["ApplyType"].ToString() != "")
                    dr["ApplyType"] = DictManageClass.GetDicNameByValue("ApplyType", dr["ApplyType"].ToString());

                if (dr["UnitType"].ToString() != "")
                    dr["UnitType"] = common.UnitType(dr["UnitType"].ToString());

                if (dr["EducationLevel"].ToString() != "")
                    dr["EducationLevel"] = DictManageClass.GetDicNameByValue("educationlevel", dr["EducationLevel"].ToString());

                if (dr["ApplyPeriodID"].ToString() != "")
                    dr["ApplyPeriodID"] = dr["ApplyPeriodID"].ToString();

                if (dr["Gender"].ToString() != "")
                    dr["Gender"] = common.GenderTypeName(dr["Gender"].ToString());

                if (dr["Applyplight"].ToString() != "")
                    dr["Applyplight"] = common.Applyplight(dr["Applyplight"].ToString());

                if (dr["ForeignLanguageName"].ToString() != "")
                    dr["ForeignLanguageName"] = OtherClass.getLanguageName(dr["ForeignLanguageName"].ToString());

                if (dr["ForeignLanguageResult"].ToString() != "")
                    dr["ForeignLanguageResult"] = DictManageClass.GetDicNameByValue("ForeignLanguageResult", dr["ForeignLanguageResult"].ToString());

                if(dr["FixedJob"].ToString()!="")
                    dr["FixedJob"] = DictManageClass.GetDicNameByValue("FixedJob", dr["FixedJob"].ToString());

                if (dr["SpecialityLevel"].ToString() != "")
                    dr["SpecialityLevel"] = DictManageClass.GetDicNameByValue("SpecialityLevel", dr["SpecialityLevel"].ToString());


                if (dr["AwardsLevel"].ToString() != "")
                    dr["AwardsLevel"] = DictManageClass.GetDicNameByValue("AwardsLevel", dr["AwardsLevel"].ToString());

                if (dr["AwardsRank"].ToString() != "")
                    dr["AwardsRank"] = DictManageClass.GetDicNameByValue("AwardsRank", dr["AwardsRank"].ToString());

                if (dr["SpecialitPersonalRank"].ToString() != "")
                    dr["SpecialitPersonalRank"] = DictManageClass.GetDicNameByValue("SpecialitPersonalRank", dr["SpecialitPersonalRank"].ToString());

                if (dr["AwardsPersonalRank"].ToString() != "")
                    dr["AwardsPersonalRank"] = dr["AwardsPersonalRank"].ToString();


                if (dr["AwardsLevel1"].ToString() != "")
                    dr["AwardsLevel1"] = DictManageClass.GetDicNameByValue("AwardsLevel", dr["AwardsLevel1"].ToString());

                if (dr["AwardsRank1"].ToString() != "")
                    dr["AwardsRank1"] = DictManageClass.GetDicNameByValue("AwardsRank", dr["AwardsRank1"].ToString());

                if (dr["SpecialityLevel1"].ToString() != "")
                    dr["SpecialityLevel1"] = DictManageClass.GetDicNameByValue("SpecialityLevel", dr["SpecialityLevel1"].ToString());

                if (dr["SpecialitPersonalRank1"].ToString() != "")
                    dr["SpecialitPersonalRank1"] = DictManageClass.GetDicNameByValue("SpecialitPersonalRank", dr["SpecialitPersonalRank1"].ToString());

                if (dr["AwardsPersonalRank1"].ToString() != "")
                    dr["AwardsPersonalRank1"] = dr["AwardsPersonalRank1"].ToString();

                DataSet dstApplyPublicity = ApplyClass.dstApplyPublicity(dr["ApplyID"].ToString());
                foreach (DataRow drPubilcity in dstApplyPublicity.Tables[0].Rows)
                {
                    dr["startmonth"] = drPubilcity["startmonth"].ToString();
                    dr["startday"] = drPubilcity["startday"].ToString();
                    dr["endmonth"] = drPubilcity["endmonth"].ToString();
                    dr["endday"] = drPubilcity["endday"].ToString();
                    dr["address"] = drPubilcity["address"].ToString();
                    dr["response"] = drPubilcity["response"].ToString();
                }

                DataSet dstThesis = ApplyClass.dstThesis(dr["ApplyID"].ToString());
                foreach (DataRow drThesis in dstThesis.Tables[0].Rows)
                {
                    switch (drThesis["SeqID"].ToString())
                    {
                        case "1":
                            dr["JournalsNo1"] = drThesis["JournalsNo"].ToString();
                            dr["ThesisTitle1"] = drThesis["ThesisTitle"].ToString();
                            dr["PeriodicalNo1"] = drThesis["PeriodicalNo"].ToString();
                            break;
                        case "2":
                            dr["JournalsNo2"] = drThesis["JournalsNo"].ToString();
                            dr["ThesisTitle2"] = drThesis["ThesisTitle"].ToString();
                            dr["PeriodicalNo2"] = drThesis["PeriodicalNo"].ToString();
                            break;
                        case "3":
                            dr["JournalsNo3"] = drThesis["JournalsNo"].ToString();
                            dr["ThesisTitle3"] = drThesis["ThesisTitle"].ToString();
                            dr["PeriodicalNo3"] = drThesis["PeriodicalNo"].ToString();
                            break;
                        case "4":
                            dr["JournalsNo4"] = drThesis["JournalsNo"].ToString();
                            dr["ThesisTitle4"] = drThesis["ThesisTitle"].ToString();
                            dr["PeriodicalNo4"] = drThesis["PeriodicalNo"].ToString();
                            break;
                        default: break;
                    }
                }

            }

            return dst;
        }
        public static DataSet getApplyInfoByApplyID(string applyid)
        {
            return ApplyClass.getApplyInfo(applyid, "", "", "");
        }
        #endregion
    }
}
